//
//  FlipsideViewController.m
//  NumberConverter
//
//  Created by Kyle on 10/25/09.
//  Copyright __MyCompanyName__ 2009. All rights reserved.
//

#import "FlipsideViewController.h"


@implementation FlipsideViewController

@synthesize delegate;

//Mutable Strings of different Bases

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
	[self.delegate setRowOfComponent1:@"Decimal"];
	[self.delegate setRowOfComponent2:@"Decimal"];
	
}


- (IBAction)done {
	
	NSLog([self.delegate rowOfComponent1]);
	NSLog([self.delegate rowOfComponent2]);
	
	[self.delegate flipsideViewControllerDidFinish:self];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView 
{
	return 2;
}

- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { // This method also needs to be used. This asks how many rows the UIPickerView will have.
	return 4;// We will need the amount of rows that we used in the pickerViewArray, so we will return the count of the array.
}


- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component 
{	
	switch (row) 
	{
		case 0:
			return @"Decimal";
			break;
		case 1:
			return @"Binary";
			break;
		case 2:
			return @"Octal";
		case 3:
			return @"Hex";
			break;
		default:
			return 0;
			break;
	}
}

-(void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
	NSLog(@"Is using this function");
	if (component == 0)
	{
		switch (row)
		{
			case 0:
				[self.delegate setRowOfComponent1:@"Decimal"];
				break;
			case 1:
				[self.delegate setRowOfComponent1:@"Binary"];
				break;
			case 2:
				[self.delegate setRowOfComponent1:@"Octal"];
				break;
			case 3:
				[self.delegate setRowOfComponent1:@"Hex"];
				break;
			default:
				[self.delegate setRowOfComponent1:@"Decimal"];
				break;
		}
	}
	else 
	{
		switch (row)
		{
			case 0:
				[self.delegate setRowOfComponent2:@"Decimal"];
				break;
			case 1:
				[self.delegate setRowOfComponent2:@"Binary"];
				break;
			case 2:
				[self.delegate setRowOfComponent2:@"Octal"];
				break;
			case 3:
				[self.delegate setRowOfComponent2:@"Hex"];
				break;
			default:
				[self.delegate setRowOfComponent2:@"Decimal"];
				break;
		}
	}

}



/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
